package curso.ejercicios;

import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

public class Dibujo extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(new RenderView(this));
	}

	class RenderView extends View {

		private Paint paint;
		private int i = 1;

		public RenderView(Context context) {
			super(context);
			paint = new Paint();
		}

		@Override
		protected void onDraw(Canvas canvas) {
			canvas.drawRGB(255, 255, 255);
			paint.setColor(Color.RED);
			i++;
			canvas.drawLine(0, 0, canvas.getWidth() - i,
					canvas.getHeight() - i, paint);
			paint.setStyle(Style.STROKE);
			paint.setColor(0xff00ff00);
			canvas.drawCircle(canvas.getWidth() / 2, canvas.getHeight() / 2,
					100, paint);
			paint.setColor(Color.CYAN);
			paint.setStyle(Style.FILL);
			canvas.drawRect(50 + i, 50, 100 + i, 100, paint);
			invalidate();
		}
	}

}
